/*
 * seqbusterAboutBox.java
 */

package seqbuster;

//import javax.swing.JFileChooser;
//import org.jdesktop.application.Action;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import seqbuster.UpTriRea.*;

public class chooseDB extends javax.swing.JDialog {

    public chooseDB() throws SQLException {
//        super(parent);
        initComponents();
        getRootPane().setDefaultButton(doad);

        nameexp.addItem("miRbase");
        //nameexp.addItem("Plants");
            

    }

    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        doad = new javax.swing.JButton();
        CloseButAdapFrame = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        nameexp = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setModal(true);
        setName("aboutBox"); // NOI18N
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(seqbuster.SeqBusterApp.class).getContext().getResourceMap(chooseDB.class);
        doad.setText(resourceMap.getString("doad.text")); // NOI18N
        doad.setName("doad"); // NOI18N
        doad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                doadActionPerformed(evt);
            }
        });
        getContentPane().add(doad, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 180, 100, -1));

        CloseButAdapFrame.setText(resourceMap.getString("CloseButAdapFrame.text")); // NOI18N
        CloseButAdapFrame.setName("CloseButAdapFrame"); // NOI18N
        CloseButAdapFrame.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CloseButAdapFrameActionPerformed(evt);
            }
        });
        getContentPane().add(CloseButAdapFrame, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 180, 90, -1));

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 120, -1, -1));

        nameexp.setName("nameexp"); // NOI18N
        getContentPane().add(nameexp, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 110, 130, 30));

        jLabel7.setFont(resourceMap.getFont("jLabel7.font")); // NOI18N
        jLabel7.setForeground(resourceMap.getColor("jLabel7.foreground")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, 290, 20));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void doadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doadActionPerformed
        // TODO add your handling code here:
        //try {
        if (nameexp.getSelectedItem().toString().contains("miRbase") ){
            try {
                JFrame mainFrame = SeqBusterApp.getApplication().getMainFrame();
                JDialog miRannFrame_obj;
                try {
                    miRannFrame_obj = new MiRNAannFrame("mb");
                    dispose();
                    miRannFrame_obj.setLocationRelativeTo(mainFrame);
                    miRannFrame_obj.setVisible(true);
                    miRannFrame_obj=null;
                    dispose();
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(chooseDB.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(chooseDB.class.getName()).log(Level.SEVERE, null, ex);
                }

                try {
                    miRannFrame_obj = new MiRNAannFrame("mb");
                } catch (FileNotFoundException ex) {
                    Logger.getLogger(chooseDB.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException ex) {
                    Logger.getLogger(chooseDB.class.getName()).log(Level.SEVERE, null, ex);
                }
               
            } catch (SQLException ex) {
                Logger.getLogger(SeqBusterView.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(null, "Error!!!!.Copy this message and send to lorena.pantano@crg.es :" + ex);
            }
        }

//        if (nameexp.getSelectedItem().toString().contains("Plants") ){
//            try {
//                JFrame mainFrame = seqbusterApp.getApplication().getMainFrame();
//                JDialog miRannFrame_obj = new MiRNAannFrame("pl");
//                dispose();
//                miRannFrame_obj.setLocationRelativeTo(mainFrame);
//                miRannFrame_obj.setVisible(true);
//                miRannFrame_obj=null;
//                dispose();
//            } catch (SQLException ex) {
//                Logger.getLogger(seqbusterView.class.getName()).log(Level.SEVERE, null, ex);
//                JOptionPane.showMessageDialog(null, "Error!!!!.Copy this message and send to lorena.pantano@crg.es :" + ex);
//            }
//        }
        Runtime.getRuntime().gc();
    }//GEN-LAST:event_doadActionPerformed

    private void CloseButAdapFrameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CloseButAdapFrameActionPerformed
        // TODO add your handling code here:
        dispose();
        Runtime.getRuntime().gc();
    }//GEN-LAST:event_CloseButAdapFrameActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CloseButAdapFrame;
    private javax.swing.JButton doad;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel7;
    public static javax.swing.JComboBox nameexp;
    // End of variables declaration//GEN-END:variables
    
}
